# 二分查找搜索二维矩阵



class Solution:
    def searchMatrix(self, matrix, target):
        i, j = len(matrix) - 1, 0

        while True:

            if not 0 <= i < len(matrix) or not 0 <= j < len(matrix[0]):
                return False
            
            if matrix[i][j] == target:
                return True
            elif matrix[i][j] < target:
                j = j + 1
            elif matrix[i][j] > target:
                i = i -1



if __name__ == "__main__":
    a = [[1,3,5,7],[10,11,16,20],[23,30,34,60]]
    t = 3
    sol = Solution()
    res = sol.searchMatrix(a, t)
    print(res)


